package com.lzx.user.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.util.Date;

/**
 * <p>
 *
 * </p>
 *
 * @author lzx
 * @since 2022-10-03
 */
@Getter
@Setter
@ApiModel(value = "User对象", description = "用户实体类")
public class User implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("编号")
    @Excel(name = "id")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @ApiModelProperty("手机号")
    @Excel(name = "手机号", width = 20, needMerge = true, desensitizationRule = "3_4")
//desensitizationRule：数据脱敏处理，3_4表示只显示字符串的前3位和后4位，其他为*号
    @NotEmpty(message = "手机号不能为空")
//    @Pattern(regexp = "^[1]([3-9])[0-9]{9}$", message = "手机号格式不正确")
    @Pattern(regexp = "^1([3-9])\\d{9}$", message = "手机号格式不正确")
    private String mobile;

    @ApiModelProperty("密码")
    @NotEmpty(message = "密码必须填写")
    @Length(min = 6, max = 18, message = "密码必须是6—18位字符")
    private String password;

    @ApiModelProperty("昵称")
    @Excel(name = "昵称", width = 20, needMerge = true)//needMerge：是否需要纵向合并单元格
    private String nickname;

    @ApiModelProperty("性别")
    @Excel(name = "性别", width = 10, replace = {"男_0", "女_1"})//replace：对属性进行替换
    private String sex;

    @ApiModelProperty("出生年月日")
    @Excel(name = "出生日期", width = 20, format = "yyyy-MM-dd")//format：当属性为时间类型时，设置时间的导出导出格式
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date birthday;

    @ApiModelProperty("头像地址")
    private String avatar;

    @ApiModelProperty("邮箱")
    @Excel(name = "邮箱", width = 20, needMerge = true)
    private String email;

    @ApiModelProperty("用户积分")
    @Excel(name = "用户积分")
    private Integer integral;

    @ApiModelProperty("简介")
    @Excel(name = "简介", needMerge = true)
    private String introduction;

    @ApiModelProperty("粉丝数")
    @Excel(name = "粉丝数")
    private Integer fansCount;

    @ApiModelProperty("关注数")
    @Excel(name = "关注数")
    private Integer attentionCount;

    @ApiModelProperty("回答数")
    @Excel(name = "回答数")
    private Integer replyCount;

    @ApiModelProperty("账号状态(0正常 1停用)")
    private String status;

    @ApiModelProperty("创建时间")
    @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty("更新时间")
    @Excel(name = "更新时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    @ApiModelProperty("ip")
    @Excel(name = "ip")
    private String ip;

    @ApiModelProperty("地址")
    @Excel(name = "地址")
    private String address;

    @ApiModelProperty("验证码")
    @TableField(exist = false)
    private String code;
}
